<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<!--css样式引入-->
<head th:replace="admin/common::head-fragment">
</head>

<body>
<!--左边工具栏-->
<nav th:replace="admin/common::navbar-fragment(active='comment.html')"></nav>

<div class="page">

    <!--顶部导航栏-->
    <header th:replace="admin/common::topbar-fragment"></header>

    <!-- Breadcrumb-->
    <!-- Content Wrapper. Contains page content -->
    <div class="content-wrapper">
        <!-- Content Header (Page header) -->
        <div class="content-header">
            <div class="container-fluid">
            </div><!-- /.container-fluid -->
        </div>
        <!-- Main content -->
        <div class="content">
            <div class="container-fluid">
                <div class="card card-primary card-outline">
                    <div class="card-header">
                        <h3 class="card-title">评论管理</h3>
                    </div> <!-- /.card-body -->
                    <div class="card-body">
                        <div class="grid-btn">
                            <button class="btn btn-info" onclick="modalShow()"><i
                                    class="fa fa-edit"></i>&nbsp;回复
                            </button>
                            <button class="btn btn-danger" onclick="deleteComments()"><i
                                    class="fa fa-trash-o"></i>&nbsp;删除
                            </button>&nbsp;&nbsp;
                            &ensp;
                            <input type="text" placeholder="关键字(标题/分类)" id="keyword" class="col-2" align="right">&nbsp;
                            <button class="btn btn-primary" onclick="search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索
                            </button>
                        </div>
                        <br/>
                        <div class="table-responsive">
                            <table class="table table-striped table-hover" style="table-layout:fixed;" >
                                <thead>
                                <tr>
                                    <th><input type="checkbox" id="checkController"/></th>
                                    <th>评论人名称</th>
                                    <th>评论内容</th>
                                    <th>评论者邮箱</th>
                                    <th>所属博客名</th>
                                    <th>回复内容</th>
                                    <th>创建时间</th>
                                </tr>
                                </thead>
                                <tbody>
                                <tr th:each="comment:${allComments}">
                                    <th scope="row"><input type="checkbox" name="checkOption" /></th>
                                    <td th:text="${comment.getId()}" name="id" style="display:none;"></td>
                                    <td th:text="${comment.getCommentator()}" name="commentator" style="word-wrap:break-word;"></td>
                                    <td th:text="${comment.getCommentBody()}" name="commentBody"></td>
                                    <td th:text="${comment.getEmail() == '' ? '未填写' : comment.getEmail()}" name="email"></td>
                                    <td th:text="${comment.getBlogName()}" name="blogName"></td>
                                    <td th:text="${comment.getReplyBody()}" name="replyBody"></td>
                                    <td th:text="${comment.getCreateTime()}" name="createTime"></td>
                                </tr>
                                </tbody>
                            </table>
                        </div>
                    </div><!-- /.card-body -->
                </div>
            </div><!-- /.container-fluid -->
        </div>
        <!-- /.content -->
    </div>

    <!--回复模态框-->
    <div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="exampleModalLabel">回复</h5>
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span>&times;</span>
                    </button>
                </div>
                <div class="modal-body">
                    <form>
                        <div class="form-group">
                            <label for="replyBody" class="col-form-label">回复内容：</label>
                            <textarea class="form-control" id="replyBody" placeholder="请输入回复内容..." rows="4" cols="8"></textarea>
                        </div>
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-secondary" data-dismiss="modal">关闭</button>
                    <button type="button" class="btn btn-primary" onclick="reply()">回复</button>
                </div>
            </div>
        </div>
    </div>
    <!--回复模态框-->

    <!--底部-->
    <footer th:replace="admin/common::footer-fragment"></footer>

</div>
<!--javascript-->
<div th:replace="admin/common::JavaScript-fragment"></div>

<!--引入自写的blog.js-->
<script th:src="@{/admin/js/comment.js}"></script>
<!-- image-picker -->
<script th:src="@{/vendor/image-picker/jquery.masonry.min.js}"></script>
<script th:src="@{/vendor/image-picker/image-picker.min.js}"></script>

</body>
</html>